{% set uniqid = uniqid ?? uniqid('version_') %}
{% set idBase = "ruby-versions-#{uniqid}" %}
{% set nameBase = "ruby[versions][#{uniqid}]" %}

{% set default = (selected_version.default is defined and selected_version.default) ? true : false %}
{% set bundler = (selected_version.bundler is defined and selected_version.bundler) ? true : false %}

<div id="{{ idBase }}" data-uniqid="{{ uniqid }}" data-name="{{ nameBase }}"
     class="tab-pane {{ active is defined and active ? 'active' }}">
    <div class="form-group col-xs-12">
        <div class="clearfix"><label>Options</label></div>

        <div class="checkbox">
            <input type="checkbox" id="{{ idBase }}-default"
                   name="{{ nameBase }}[default]"
                   value="1"
                   {% if default %}checked{% endif %} />
            <label for="{{ idBase }}-default">
                Set as default
            </label>
            <div class="help-block">
                Set this as system-wide default version.
                Don't set more than one version as default.
            </div>
        </div>

        <div class="checkbox">
            <input type="checkbox" id="{{ idBase }}-bundler"
                   name="{{ nameBase }}[bundler]"
                   value="1"
                   {% if bundler %}checked{% endif %} />
            <label for="{{ idBase }}-bundler">
                Install Bundler
            </label>
            <div class="help-block">
                The best way to manage a Ruby application's gems.
                <a href="http://bundler.io/" target="_blank">More information</a>
            </div>
        </div>
    </div>

    <div class="clearfix"></div>

    <div class="form-group col-xs-12 col-sm-6">
        <label for="{{ idBase }}-version">
            Choose Version
        </label>
        <select id="{{ idBase }}-version"
                name="{{ nameBase }}[version]"
                class="form-control select-tag-editable">
            {% if selected_version.version and selected_version.version not in available_versions %}
                <option value="{{ selected_version.version }}" selected>{{ selected_version.version }}</option>
            {% endif %}
            {% for available in available_versions %}
                <option value="{{ available }}"
                    {% if available == selected_version.version %}selected{% endif %}>{{ available }}</option>
            {% endfor %}
        </select>
        <div class="help-block">
            Choosing Ruby <= 1.9.2 requires compiling. This will take time!
            All others have binaries available.
        </div>
    </div>

    <div class="form-group col-xs-12 col-sm-6">
        <label for="{{ idBase }}-gems">
            Installed Gems
        </label>
        <select id="{{ idBase }}-gems"
                multiple name="{{ nameBase }}[gems][]"
                class="form-control select-tags-editable">
            {% if selected_version.gems is defined %}
                {% for gem in selected_version.gems %}
                    <option selected value="{{ gem }}">{{ gem }}</option>
                {% endfor %}
            {% endif %}
        </select>
        <div class="help-block">
            To install a specific version, use <code>{gem}@{version}</code>.
            eg: <code>rails@4.1.3</code>. For latest just use <code>{gem}</code>.
        </div>
    </div>

    <div class="clearfix"></div>
</div>
